/*
This code creates Figure 1,
a histogram of the distribution of ACA-induced cuts to MA in 2017
*/

log using "$logs\Fig1.txt", replace text name(fig1)

use "$data_deri\enroll_panel", clear
keep stcty statename countyname eligibles11
duplicates drop stcty, force
tempfile panel_counties
save `panel_counties'

use "$data_deri\ratedata_17", clear
merge 1:1 stcty using `panel_counties'
keep if _merge==3

sum bnch_cut_prop, detail
_pctile bnch_cut_prop, p(75,99)
local p75 = r(r1)
local p99 = r(r2)
disp "`p75' `p99'"

histogram bnch_cut_prop if bnch_cut_prop < `p99', ///
freq width(2) ytitle("Number of Counties") ylabel(0(200)1200) ytick(0(100)1200) ///
xtitle("Benchmark Cut (%)") xline(`p75') text(1000 9.01 "75th" "Percentile", place(r)) scheme(burd)

graph export "$output\Fig1.pdf", replace

log close fig1
